package Search;



public class BinarySearch {

    public static void main(String[] args) {
        int[] arr={5,18,23,36,48,59,68,75,82,91,103};
        int result=binarySearch(arr,5);
        System.out.println(result);
    }

    public static int binarySearch(int[] arr,int key){
        int min=0;
        int max=arr.length-1;
        int mid=(min+max)/2;
        while(min<max){
            if(arr[mid]==key){
                return mid;
            }
            else if(arr[mid]<key){
                min=mid+1;

            }
            else{
                max=mid-1;
            }
            mid=(min+max)/2;
        }
        return -1;
    }
}
